<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
       <p> {{count}}</p>
       <button @click="increate">+</button>
    </div>
    <script type="module">
        import {createApp,ref} from './node_modules/vue/dist/vue.esm-browser.js'
        function useCount (){
            // 转换为响应式对象
            // 基础数据类型内部是值，不可能转换为响应式对象，内部会创建一个只有 value 属性的对象，value 属性有 getter/setter
            // ref 如果是对象，会调用 reactive 返回代理对象
            const count = ref(0)
            return {
                count,
                increate(){
                    count.value ++
                }
            }
        }
        const app = createApp({
          setup(){
            return {
               ...useCount()
            }
          },
          mounted(){
              this.count += 10
          }
        }).mount('#app')
    </script>
</body>

</html>